﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>个人资料</title>
    @Html.Style("~/scripts/layuiadmin/layui/css/layui.css")
    @Html.Style("~/scripts/layuiadmin/style/admin.css")
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header">个人资料</div>
            <div class="layui-card-body" style="padding: 15px;">
                <table class="layui-table">
                    <colgroup>
                        <col width="100">
                        <col>
                    </colgroup>
                    <tbody>
                        <tr>
                            <td style="width:120px;">用户名</td>
                            <td>@ViewBag.User.UserName</td>
                        </tr>
                        <tr>
                            <td style="width:120px;">到期时间</td>
                            <td>
                                @ViewBag.User.ExpireDate.ToString("yyyy-MM-dd HH:mm:ss")
                            </td>
                        </tr>
                        <tr>
                            <td style="width:120px;">上次登录IP</td>
                            <td>
                                @ViewBag.User.LastLoginIp
                            </td>
                        </tr>
                        <tr>
                            <td style="width:120px;">上次登录时间</td>
                            <td>@ViewBag.User.LastLoginTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                        </tr>
                        <tr>
                            <td style="width:120px;">客户端验证码</td>
                            <td><span id="code">@ViewBag.User.Code</span><button class="layui-btn layui-btn-xs" style="margin-left:10px;" id="btnModifyCode">修改</button></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    @Html.Script("~/scripts/layuiadmin/layui/layui.js")
    <script type="text/javascript">
        var dataTableObj = undefined;
        layui.use(['form', 'layer', 'table', 'upload', 'element'], function () {
            var layer = layui.layer,
                form = layui.form,
                element = layui.element,
                $ = layui.$;

            $('#btnModifyCode').click(function () {
                layer.prompt({
                    formType: 0,
                    value: $('#code').text(),
                    offset: '165px',
                    title: '修改客户端验证码'
                }, function (value, index, elem) {
                    if (value.length >= 6 && value.length <= 10) {
                        $.post('/admin/modify-code', {
                            code: value
                        }, function (data) {
                            if (data.code == 1) {
                                layer.close(index);
                                $('#code').text(value);
                                layer.msg('修改成功');
                            } else {
                                layer.msg(data.msg);
                            }
                        });
                    } else {
                        layer.msg('验证码 6 到 10 位');
                    }
                });
            });

            $('#btnOk').click(function () {
                var passwords = form.val('form-filter');

                if (passwords.password.length < 6 || passwords.password.length > 12) {
                    layer.msg('密码6-12位');
                    return;
                }

                if (passwords.password != passwords.okPassword) {
                    layer.msg('两次输入密码不一致');
                    return;
                }

                $.post('/admin/modify-password', {
                    password: passwords.password
                }, function (data) {
                    if (data.code == 1) {
                        layer.msg('修改成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            });
        });
</script>
</body>
</html>
